package test.mdd

import org.goodsl.mdd.Seg
import org.goodsl.mdd.annotation.ValueType
import org.goodsl.mdd.Box
import org.junit.Test
import org.goodsl.mdd.BoxBuilder
import org.goodsl.mdd.paint.BoxPainter

/**
 * Created with IntelliJ IDEA.
 * User: simonxiao
 * Date: 12-11-25
 * Time: 下午5:28
 * Copyright goodsl.org 2012~2020
 */
class TestPainter {

    @Test
    void testPainterBoxFromValues(){
        OneBox b0 = (OneBox)BoxBuilder.makeBox(OneBox.class)

        b0.age 30
        b0.name "Simon"

        HashMap<String,Object> values = b0.getSegValues()

        BoxPainter  p1 = new BoxPainter(OneBox.class,values)

        OneBox  b1 = (OneBox)p1.box
        assert  b1.age() == b0.age()
        assert  b1.name() == b0.name()
    }

}

class OneBox extends Box {

    OneSeg age
    TwoSeg name

}

@ValueType(int)
class OneSeg extends Seg{

}

@ValueType(String)
class TwoSeg extends Seg{

}
